package com.example.jixeishi1.service;


import com.example.jixeishi1.dao.CartMapper;
import com.example.jixeishi1.dao.OrderShopMapper;
import com.example.jixeishi1.entity.CartEntity;
import com.example.jixeishi1.entity.OrderShopEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class OrderShopService {
    @Resource
    OrderShopMapper orderShopMapper;
    @Resource
    CartMapper cartMapper;
    public List<OrderShopEntity> getorderShopAll() {
        List<OrderShopEntity> orderShopEntities = orderShopMapper.getorderShopAll();
                return orderShopEntities;
    }

    public void saveordershop(Integer id) {
            CartEntity cartEntity = cartMapper.getShoppingInfoById(id);
            OrderShopEntity orderShopEntity = new OrderShopEntity();
            BeanUtils.copyProperties(cartEntity,orderShopEntity);
            orderShopMapper.saveordershop(orderShopEntity);

    }

    public void checkAll(Integer id) {
        orderShopMapper.delorderall();
            CartEntity cartEntity = cartMapper.getShoppingInfoById(1);
            OrderShopEntity orderShopEntity = new OrderShopEntity();
            orderShopEntity.setId(200);
            orderShopEntity.setCmmodityName("1");
            orderShopEntity.setCommodityId(1);
            orderShopEntity.setInTime(new Date());
            orderShopEntity.setNum(1);
        orderShopEntity.setPricecommodity(0.00);
        orderShopEntity.setSubtitle("1");
            orderShopMapper.saveordershop(orderShopEntity);

    }

    public void delete(Integer id) {
                    orderShopMapper.delordershop(id);
    }

    public void delordershop(Integer id) {
        orderShopMapper.delordershop(id);

    }
}
